<?php
namespace app\index\model;
class Autorun extends BaseModel
{
    
    
    function startrun() {
        ignore_user_abort();        // 后台运行
        set_time_limit(0);          // 取消脚本运行时间的超时上限
        $file = "jclock.php";
        $fp = fopen($file, "w");
        flock($fp, LOCK_EX|LOCK_NB);
        
        
        $jcaccount = new Jccount();
        $local = $jcaccount->getLock();
        $times = $local['times'];
        $socket = new Socket();
        while($times>0)
        {
           
           $local = $jcaccount->getLock();
           $times = $local['times'];
           if ($times>0){
               sleep(1);
           }
        }
        $jcaccount->kaijaing($local);
        flock($fp, LOCK_UN); // 解锁
        fclose($fp);
        exit();
    }
    
    
}
